<%@ page import="com.ld.businesscard_manage.service.BusinessCardService" %>
<%@ page import="com.ld.businesscard_manage.service.impl.BusinessCardServiceImpl" %>
<%@ page import="com.ld.businesscard_manage.bean.User" %>
<%@ page import="com.ld.businesscard_manage.bean.BusinessCard" %><%--
  Created by IntelliJ IDEA.
  User: 刘邓
  Date: 2023-06-10
  Time: 16:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加我的名片结果</title>
</head>
<body>
<%!
    private BusinessCardService cardService = new BusinessCardServiceImpl();
%>
<%
    User user = (User)(session.getAttribute("user"));
    String name = request.getParameter("name");
    String sex0 = request.getParameter("sex");
    String account = user.getUsername();
    String password = user.getPassword();
    String email = request.getParameter("email");
    if (name == "") response.sendRedirect("/home/addCard.jsp");
    else if (sex0 == "") response.sendRedirect("/home/addCard.jsp");
    else if (email == "") response.sendRedirect("/home/addCard.jsp");
    else {
        Integer sex = Integer.parseInt(sex0);
        BusinessCard card = new BusinessCard();
        card.setName(name);
        card.setSex(sex);
        card.setAccount(account);
        card.setPassword(password);
        card.setEmail(email);
        card.setValid(0);
            int i = cardService.addCard(card);
            if (i == 0 ) {
                out.println("<h1>添加失败</h1>");
            } else {
                out.println("<h1>添加成功</h1>");
            }

    }
    out.println("<a href='/home/myCard.jsp'>返回个人名片页面</a>");
%>
</body>
</body>
</html>
